package com.jeeplus.common.utils;

import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

public class UploadUtils {
    private static String filePath;
    public static String requestUpload(MultipartFile file) throws Exception {
        String originalFilename = file.getOriginalFilename();
        if (originalFilename != null) {
            int index = originalFilename.lastIndexOf(".");
            String extname = originalFilename.substring(index);
            String name = originalFilename.substring(0, index);
            String fileName= UUID.randomUUID()+name+extname;
            filePath="D:\\DemoYa\\jp-console\\jeeplus-platform\\jeeplus-common\\src\\main\\java\\com\\jeeplus\\common\\localFile\\"+fileName;//文件路径测试为本地，可改为线上
            file.transferTo(new File(filePath));
        }
        return filePath;
    }
}
